package com.newland.zxy;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.InputStream;
import java.util.Properties;

/**
 * @author zhangxuyuan
 * @version 1.0
 * @date 2021/1/12
 */
public class MyPropertiesUtil {

    private static Logger logger = LogManager.getLogger(MyPropertiesUtil.class);

    public static Properties props;

    public static String getValueForString(String key) {
        if (props == null) {
            getProperties();
        }
        return String.valueOf(props.get(key));
    }

    public static void getProperties() {
        logger.info(DBUtil.class.getClassLoader().getResource("nl_dsNonusePool.properties"));
        try (InputStream in = DBUtil.class.getClassLoader()
            .getResourceAsStream("nl_dsNonusePool.properties");) {
            props = new Properties();
            props.load(in);
        } catch (Exception ex) {
            logger.error("init Properties error", ex);
        }
    }
}
